package com.yyh.synctool.client.util;

import com.yyh.synctool.client.constant.DB;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * @author xuan
 * @date 2021/12/13
 */
public class DBTest
{
    public static boolean test(String type, String url, String username, String password) {
        DB db = DB.getInstance(type);
        if (null == db) {
            return false;
        }

        try {
            Class<?> clzz = Class.forName(db.getDriverName());
            Connection conn = DriverManager.getConnection(url, username, password);
            conn.close();
            return true;
        } catch (Exception e) {
            return false;
        }
    }
}
